<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
	th:with="title='文章管理',active='article'">
<header th:replace="admin/header::headerFragment(${title},${active})"></header>
<body class="fixed-left">
	<div id="wrapper">
		<div th:replace="admin/header::header-body"></div>
		<div class="content-page">
			<div class="content">
				<div class="container">
					<div class="row">
						<div class="col-sm-12">
							<h4 class="page-title">文章管理</h4>
						</div>
						<div class="col-md-12">
							<table class="table table-striped table-bordered">
								<thead>
									<tr>
										<th width="25%" style="text-align:center">文章标题</th>
										<th width="15%" style="text-align:center">发布时间</th>
										<th style="text-align:center">浏览量</th>
										<th style="text-align:center">所属分类</th>
										<th width="8%" style="text-align:center">发布状态</th>
										<th width="8%" style="text-align:center">是否置顶</th>
										<th style="text-align:center">操作</th>
									</tr>
								</thead>
								<tbody style="text-align:center">
									<th:block th:each="post : ${pageInfo.list}" >
										<tr th:id="${post.id}">
											<td><a th:href="@{'/admin/article/'+${post.id}}"
												th:text="${post.title}"></a></td>
											<td><th:block th:text="${post.date}" /></td>
											<td><th:block th:text="${post.viewnum}" /></td>
											<td><th:block th:text="${post.category}" /></td>
											<td><th:block>
													<span class="label label-success">已发布</span>
												</th:block></td>
											<td><th:block th:switch="${post.top}">
													<span class="label label-success" th:case="1">置顶</span>
													<span class="label label-success" th:case="0">不置顶</span>
												</th:block></td>
											<td><a th:href="@{'/admin/article/modify/'+${post.id}}"
												class="btn btn-primary btn-sm waves-effect waves-light m-b-5"><i
													class="fa fa-edit"></i> <span>编辑</span></a> <a
												href="javascript:void(0)"
												th:onclick="'delPost('+${post.id}+');'"
												class="btn btn-danger btn-sm waves-effect waves-light m-b-5"><i
													class="fa fa-trash-o"></i> <span>删除</span></a> <a
												class="btn btn-warning btn-sm waves-effect waves-light m-b-5"
												target="_blank"><i class="fa fa-rocket"></i> <span>预览</span></a>
											</td>
										</tr>
									</th:block>

								</tbody>
							</table>
							<!-- 分页开始 -->
							<div>
								<div class="clearfix">
									<ul class="pagination m-b-5 pull-left">
										<li th:if="${pageInfo.hasPreviousPage}"><a
											th:href="@{'/blog/admin/article?page='+${pageInfo.prePage}}"
											aria-label="Previous"> <i class="fa fa-angle-left"></i>&nbsp;上一页
										</a></li>

										<th:block th:each="nav : ${pageInfo.navigatepageNums}">
											<li th:class="${nav==pageInfo.pageNum}?'active':''"><a
												th:href="@{'/admin/article?page='+${nav}}" th:text="${nav}"></a></li>
										</th:block>

										<th:block th:if="${pageInfo.hasNextPage}">
											<li><a
												th:href="@{'/admin/article?page='+${pageInfo.nextPage}}"
												aria-label="Next"> 下一页&nbsp;<i class="fa fa-angle-right"></i>
											</a></li>
										</th:block>

										<li><span th:text="'共'+${pageInfo.pages}+'页'"></span></li>
									</ul>
								</div>
							</div>
							<!-- 分页结束 -->

						</div>
					</div>
					<div th:replace="admin/footer :: footer-content"></div>
				</div>
			</div>
		</div>
	</div>
	<div th:replace="admin/footer :: footer"></div>
	<script type="text/javascript">
		var tale = new $.tale();
		function delPost(id) {
			tale.alertConfirm({
				title : '确定删除该文章吗?',
				then : function() {
					tale.post({
						url : '/blog/admin/article/delete',
						data : {
							id : id
						},
						success : function(result) {
							if (result.msg == "success") {
								tale.alertOkAndReload('文章删除成功');
								Pause(this, 200);
								window.location.reload();
							} else {
								tale.alertError(result.msg || '文章删除失败');
							}
						}
					});
				}
			});
		}
	</script>
</body>
</html>